<template>
  <div>
    <!-- 头部:订单管理 -->
    <div><Navbar :title="title" :xiaoming="reserve" class="hha" /></div>
    <el-row> </el-row>
    <!-- 查询重置 -->
    <div class="search">
      <el-form ref="form" :model="form" label-width="50px" class="top">
        <el-form-item label="用户名称" :label-width="formLabelWidth">
          <el-input v-model="form.hh1"></el-input>
        </el-form-item>
        <el-form-item label="评论内容" :label-width="formLabelWidth">
          <el-input v-model="form.hh2"></el-input>
        </el-form-item>
      </el-form>
      <el-form class="reset">
        <el-form-item class="query">
          <el-button type="primary" @click="onSubmit">新增</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onReset">重置</el-button>
        </el-form-item>
      </el-form>
    </div>

    <!-- 订单表单 -->
    <el-table
      ref="singleTable"
      :data="shujv"
      highlight-current-row
      @current-change="handleCurrentChange"
      style="width: 800px"
    >
      <el-table-column type="index" label="序号" width="110"> </el-table-column>
      <!-- 用户名称 -->
      <el-table-column property="uname" label="用户名称" width="100">
      </el-table-column>
      <!-- 评论 -->
      <el-table-column property="talks" label="评论内容" width="300">
      </el-table-column>

      <!-- 评论时间 -->
      <el-table-column property="comttime" label="评论时间" width="140">
      </el-table-column>
      <!-- 是否推荐 -->
      <el-table-column prop="bool" label="是否推荐">
        <template slot-scope="scope">
          <el-switch
            v-model="scope.row.tool"
            active-color="#13ce66"
            inactive-color="#ff4949"
          >
          </el-switch>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      layout="prev, pager, next"
      @current-change="pagnum($event)"
      :total="total"
      :current-page.sync="current"
      :page-size="size"
    >
    </el-pagination>
  </div>
</template>

  <script>
import Navbar from "../../components/NavBar.vue";
import { comment, update } from "../../api/jie/api.js";
export default {
  components: {
    Navbar,
  },
  data() {
    return {
      dialogFormVisible: true,
      form: {
        hh1: "",
        hh2: "",
        hh3: "",
      },
      formLabelWidth: "100px",
      tableData: [{ oid: "1" }],

      current: 1,
      size: 5,
      total: 0,
      shujv: [],
      title: "评论管理",
      reserve: "返回上一页",
      ccoid: 50,
      ddoid: 0,
      eeoid: 0,
    };
  },

  methods: {
    handleCurrentChange(val) {
      this.currentRow = val;
    },
    // 返回上一页
    fun() {
      this.$router.go(-1);
    },
    //新增
    onSubmit() {
      console.log("reset!", this.form);
      this.ccoid = this.ccoid + 1;
      this.eeoid = this.ccoid;
      this.ddoid = this.eeoid;
      update(
        this.ddoid,
        "2023-02-10T08:18:20.421Z",
        this.form.hh2,
        this.form.hh1
      ).then((ok) => {
        console.log(ok, 89);
        this.form = {};
        this.$message({
          message: "添加成功",
          type: "success",
        });
      });
      comment(1, 100).then((ok) => {
        console.log(ok.data.records);
        this.shujv = ok.data.records;
        console.log(this.shujv, 9);
      });
    },
    pagnum(i) {
      console.log(i);
      comment(i, 5).then((ok) => {
        console.log(ok.data.records);
        this.shujv = ok.data.records;
        console.log(this.shujv, 9);
      });
    },
    // 重置
    onReset() {
      console.log("reset!", this.form);
      this.form = {};
    },
  },

  // 获取全部数据
  mounted() {
    comment(1, 5).then((ok) => {
      console.log(ok.data.records);
      this.shujv = ok.data.records;
      console.log(this.shujv, 9);
      console.log(ok.data.total);
      this.total = ok.data.total;
      console.log(this.total);
    });
  },
};
</script>
  
  <style scoped lang="scss">
.hh3 {
  margin-left: 30px;
}
.hha {
  background: #eee;
}
.el-table {
  margin: auto;
  margin-top: 50px;
  margin-bottom: 50px;
}

.el-col-24 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 0 20px 0;
  padding: 0 140px 0 8px;
  border-left: 5px rgb(80, 176, 227) solid;
  .el-button {
    height: 40px;
  }
}

.block {
  .demonstration {
    display: inline-block;
    margin-right: 12px;
  }
}

.pay {
  margin-left: 11px;
}
.last {
  display: flex;
  justify-content: center;
  padding-right: 10px;
}
img {
  width: 60px;
}

.el-pagination {
  margin-top: 20px;
}
.search {
  display: flex;
  justify-content: space-between;
}

.top {
  display: flex;
  flex-wrap: wrap;
  .el-form-item {
    width: 320px;
  }
}
.reset {
  width: 560px;
  display: flex;
  justify-content: center;
  .query {
    padding: 0 10px 0 82px;
  }
}
.block {
  padding-left: 30px;
}
.el-button {
  margin-left: 10px;
}
</style>